package com.tim.dao.Impl;

import com.tim.dao.UserDao;
import com.tim.pojo.User;
import com.tim.util.JDBCUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * 作者：Tim
 * 时间：2021/4/25 14:32
 */
public class UserDaoImpl implements UserDao {
    @Override
    public User selectByname(String username) throws SQLException {
        QueryRunner qr = new QueryRunner(JDBCUtils.getDataSource());
        String sql = "select * from user where username = ? ";
        Object[] args = {username};
        return qr.query(sql,new BeanHandler<User>(User.class),args);
    }
}
